package com.weiz.controller;

import com.weiz.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    private static final Logger logger = LoggerFactory.getLogger(TestController.class);

    @Autowired
    private UserService userService;

    @PostMapping("doTest")
    public String doTest(@RequestParam("name") String name) throws InterruptedException {
        logger.info("入参 name={}",name);
        testTrace();
        logger.info("调用结束 name={}",name);
        return "Hello,"+name;
    }
    private void testTrace(){
        logger.info("这是一行info日志");
        logger.error("这是一行error日志");
        testTrace2();
    }
    private void testTrace2(){
        logger.info("这也是一行info日志");
        try {
            userService.insertUser();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
